<style>
    .find-detail-wrapper .info-bar>img {
        margin-bottom: .25rem;
        display: block;
    }
    .find-detail-wrapper {
        padding-bottom: 2.8rem;
    }
</style>
<!--<div class="am-form-group">-->
<!--&lt;!&ndash;图片集&ndash;&gt;-->
<!--{volist name="images" id="vo"}-->
<!--<img src="__CDN__{$vo}" />-->
<!--{/volist}-->
<!--</div>-->
<div class="find-app" id="urlHistory">
    <!-- public-head -->
    <div class="header-mobile">
        <div class="nav-back" @click="checkHistory">
            <img class="icon" src="__CDN__/assets/img/return@2x.png" alt="">
        </div>
        <h1 class="nav-title">详情</h1>
    </div>
    <!-- main-wrapper -->
    <div class="main-wrapper">
        <div class="find-detail-wrapper">
            <div class="section-floor">
                <div class="head">
                    <div class="user-info">
                        <img class="avatar" src="{$something.user.avatar}" alt="">
                        <div>
                            <p class="name">{$something.contacts}</p>
                            <p class="time">{$something.createtime}</p>
                        </div>
                    </div>
                    {if condition="$chat_url neq 1"}
                    <a class="link-btn" href="{$chat_url}">联系Ta</a>
                    {else /}
                    {/if}

                </div>
                <div class="info-bar">
                    <span class="label">{$something.label}</span>
                    {$something.content}
                    {volist name="something.images" id="vo"}
                    <img width="300px" src="{$vo}">

                    {/volist}
                </div>
                <div class="location-bar">
                    <div>
                        <img class="icon" src="__CDN__/assets/img/icon-map@2x.png" alt="">
                        <span>{$something.detailedaddress}</span>
                    </div>
                    <div>
                        <span>浏览 {$something.browse}</span>
                    </div>
                </div>
                <div class="reward-bar">
                    <div class="inner">
                        <span class="reward">赏金</span>
                        <span class="symbol">￥</span>
                        <span class="price">{$something.money}</span>
                    </div>
                    <span class="could">分享预计可获得￥{$money}</span>
                </div>
            </div>

        </div>
    </div>
    <!-- footer-findout -->
    {if condition="$something.status >0 "}
    {if condition="$something.status<2 "}
        <div class=" footer-findout">
        {if condition="$something.receiverUserId eq 0 "}
        {if condition="$something.type eq 1 "}
            {if condition="$chat_url neq 1"}
        <a class="btn findout" href="{:url('user/claim',array('id'=>$id))}">失物招领</a>
            {/if}
        {else}
            {if condition="$chat_url neq 1"}
        <a class="btn findout" href="{:url('user/eureka',array('id'=>$id))}">我找到了</a>
            {/if}
        {/if}

        <a class="btn share" @click="share({$something.id})">立即分享</a>
        {/if}
</div>
{/if}
    {/if}
<!-- public-toast 弹窗在这里，自己修改参数就可以了 -->
<div v-if="shareToast.show" class="mask-mobile" @click.self="shareToast.show = false">
    <div class="toast-mobile">
        <div class="toast-wrapper">
            <div class="toast-head">
                <h1 class="title">分享</h1>
                <div class="main">
                    <p class="txt">1、有赏爱心传递，预计可赚￥{{shareToastData.share}}</p>
                    <p class="txt">2、邀请好友成功分享后，您可获得好友佣 金的{{shareToastData.employe}}%</p>
                </div>
            </div>
            <div class="toast-footer">
                <div class="btn invite-btn" @click="friends()">取消</div>
                <div class="btn share-btn" @click="circle()">分享</div>
            </div>
        </div>
    </div>
</div>
<!-- public_share -->
<div v-if="shareFirend" class="mask-share-friend">
    <div class="btn-wrapper"><img @click.self="shareFirend = false" class="share-fiend-btn"
            src="__CDN__/assets/img/share_close.png" /><img class="share-fiend-btn"
            src="__CDN__/assets/img/share_firend.png" alt=""></div>
    <div class="tip">
        <p>请点击右上角</p>
        <p>通过【发送给朋友】或【分享到朋友圈】</p>
        <p>将有赏爱心传递下去</p>
    </div>
</div>

</div>
<!--href="javascript:history.go(-1)"-->
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js" type="text/javascript" charset="utf-8"></script>

<script>
    wx.config(<?php echo $js->config(array('onMenuShareAppMessage','onMenuShareTimeline','getLocation'), false) ?>);
    let urlHistory = new Vue({
        el: '#urlHistory',
        data: {
            shareToast: {
                show: false,
            },
            shareToastData: [],
            shareFirend: false,
            shareid: '{$something.id}'
        },
        mounted() {
            let self = this;
            this.shareTrue()
            var t;
            clearTimeout(t)
            t = setTimeout(function () {
                self.sharetimeout()
            }, 1500);
            console.log(window.history)
        },
        methods: {
            checkHistory() {
                if (window.history.length == 1) {
                    window.location.href ="{:url('index/index')}"
                } else if (window.history.length > 1) {
                    window.history.go(-1)
                } else {
                    window.history.go(-1)
                }
            },
            shareTrue() {

                let self = this;
                axios({
                    method: "post",
                    url: "{:url('index/getShareLink')}",
                    data: {
                        something_id: self.shareid
                    },
                    headers: {
                        'X-Requested-With': 'XMLHttpRequest'
                    }
                }).then(res => {
                    if (res.data.code == 1) {

                        self.shareToastData = res.data.data


                    } else {}
                });


            },
            sharetimeout() {
                let self = this
                wx.onMenuShareTimeline({
                    title: self.shareToastData.title,
                    link: self.shareToastData.link,
                    imgUrl: self.shareToastData.imgUrl,
                    // imgUrl: 'http://demo.open.weixin.qq.com/jssdk/images/p2166127561.jpg',
                    trigger: function (res) {
                        // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
                        // alert('用户点击分享到朋友圈');
                    },
                    success: function (res) {
                        axios({
                            method: "post",
                            url: "{:url('index/index')}",
                            data: {
                                RequestName: 'share',
                                something_id: self.shareid
                            },
                            headers: {
                                'X-Requested-With': 'XMLHttpRequest'
                            }
                        }).then(res => {})
                        self.$messagebox("已分享")
                    },
                    cancel: function (res) {
                        alert('已取消');
                    },
                    fail: function (res) {
                        alert(JSON.stringify(res));
                    }
                });

                wx.onMenuShareAppMessage({
                    title: self.shareToastData.title,
                    desc: self.shareToastData.desc,
                    link: self.shareToastData.link,
                    imgUrl: self.shareToastData.imgUrl,
                    // imgUrl: 'http://demo.open.weixin.qq.com/jssdk/images/p2166127561.jpg',
                    trigger: function (res) {
                        // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容
                    },
                    success: function (res) {
                        axios({
                            method: "post",
                            url: "{:url('index/index')}",
                            data: {
                                RequestName: 'share',
                                something_id: self.shareid
                            },
                            headers: {
                                'X-Requested-With': 'XMLHttpRequest'
                            }
                        }).then(res => {

                        })
                        self.$messagebox("已分享")

                    },
                    cancel: function (res) {
                        self.$messagebox('已取消');
                    },
                    fail: function (res) {
                        self.$messagebox(JSON.stringify(res));
                    }

                });
            },
            share(id) {
                let self = this;
                self.shareid = id
                axios({
                    method: "post",
                    url: "{:url('index/getShareLink')}",
                    data: {
                        something_id: id
                    },
                    headers: {
                        'X-Requested-With': 'XMLHttpRequest'
                    }
                }).then(res => {

                    if (res.data.code === 1) {
                        self.shareToastData = res.data.data
                        self.shareToast.show = true

                    } else {}
                });
            },
            friends() {
                this.shareToast.show = false
            },
            circle() {
                this.shareToast.show = false
                this.shareFirend = true

                console.log(this.shareFirend)
                let self = this
                wx.onMenuShareTimeline({
                    title: self.shareToastData.title,
                    link: self.shareToastData.link,
                    imgUrl: self.shareToastData.imgUrl,
                    // imgUrl: 'http://demo.open.weixin.qq.com/jssdk/images/p2166127561.jpg',
                    trigger: function (res) {
                        // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容，因为客户端分享操作是一个同步操作，这时候使用ajax的回包会还没有返回
                        // alert('用户点击分享到朋友圈');
                    },
                    success: function (res) {
                        axios({
                            method: "post",
                            url: "{:url('index/index')}",
                            data: {
                                RequestName: 'share',
                                something_id: self.shareid
                            },
                            headers: {
                                'X-Requested-With': 'XMLHttpRequest'
                            }
                        }).then(res => {})
                        self.$messagebox("已分享")
                    },
                    cancel: function (res) {
                        alert('已取消');
                    },
                    fail: function (res) {
                        alert(JSON.stringify(res));
                    }
                });

                wx.onMenuShareAppMessage({
                    title: this.shareToastData.title,
                    desc: this.shareToastData.desc,
                    link: this.shareToastData.link,
                    imgUrl: self.shareToastData.imgUrl,
                    // imgUrl: 'http://demo.open.weixin.qq.com/jssdk/images/p2166127561.jpg',
                    trigger: function (res) {
                        // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容

                    },
                    success: function (res) {
                        axios({
                            method: "post",
                            url: "{:url('index/index')}",
                            data: {
                                RequestName: 'share',
                                something_id: self.shareid
                            },
                            headers: {
                                'X-Requested-With': 'XMLHttpRequest'
                            }
                        }).then(res => {

                        })
                        self.$messagebox("已分享")

                    },
                    cancel: function (res) {
                        self.$messagebox('已取消');
                    },
                    fail: function (res) {
                        alert(JSON.stringify(res));
                    }

                });

            }
        }
    })
</script>